// components/commentItem/commentItem.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    commentItem:{
      type:Object,
      value:{}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    addTime:""
  },

  attached(){
    this.formateTime();
  },
  /**
   * 组件的方法列表
   */
  methods: {
    formateTime(){
      let time =parseInt(this.properties.commentItem.addtime) ;
      let date = new Date(time*1000);
      let mm = date.getMonth()+1;
      let dd = date.getDate();
      let h = date.getHours();
      let m = date.getMinutes();
      mm = mm < 10 ? "0" + mm : mm
      dd = dd < 10 ? "0" + dd : dd
      h  = h  < 10 ? "0" + h  : h 
      m  = m  < 10 ? "0" + m  : m 
      let str = `${mm}-${dd} ${h}:${m}`;
      this.setData({
        addTime:str
      })
    }
  }
})
